<tagLib name="lbase"/>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>微信公众平台管理系统</title>
        <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">
    <include file="Public:header" />
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="__PUBLIC__/js/html5.js"></script>
    <![endif]-->
</head>

<!--[if lt IE 7 ]> <body class="ie ie6"> <![endif]-->
<!--[if IE 7 ]> <body class="ie ie7 "> <![endif]-->
<!--[if IE 8 ]> <body class="ie ie8 "> <![endif]-->
<!--[if IE 9 ]> <body class="ie ie9 "> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> 
<body class="">
    <!--<![endif]-->

    <!--顶部菜单-->
<include file="Public:navbar" />

<!--左侧导航条-->
<include file="Public:nav" />

<!--右侧整体区域-->
<div class="content">
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="row-fluid">
                <!--右侧栏目区域start-->
                <div class="block">
                    <a class="block-heading" data-toggle="collapse">秒杀活动添加</a>
                    <div class="block-body collapse in">

                        <div class="container-fluid" style="margin-top: 10px;">
                            <!--右侧栏目内容区域start-->
                            <div class="row">
                                <div class="span12">
                                    <div class="pull-left">
                                        <a href="{:U('/'.$module_name)}" class="btn btn-primary">列 表</a>&nbsp;&nbsp;
                                        <a class="btn btn-primary" href="{$pre_url}">返 回</a>
                                    </div>
                                </div>
                                <!--右侧字段区域start-->
                                <div class="span12" style="margin-top:10px;">
                                    <form class="form-horizontal" method="post">
                                        <fieldset>
                                            <div id="legend" class="">
                                                <legend class=""></legend>
                                            </div>
                                            <div class="control-group">

                                                <!-- Text input-->
                                                <label class="control-label" for="input01">秒杀活动标题</label>
                                                <div class="controls">
                                                    <input type="text" placeholder="" name="goods_title" class="input-xlarge">
                                                    <p class="help-block"></p>
                                                </div>
                                            </div>

                                            <div class="control-group">

                                                <!-- Text input-->
                                                <label class="control-label" for="input01">商品名称</label>
                                                <div class="controls">
                                                    <input type="text" placeholder="" name="goods_name" class="input-xlarge">
                                                    <p class="help-block"></p>
                                                </div>
                                            </div>

                                            <div class="control-group">

                                                <!-- Text input-->
                                                <label class="control-label" for="input01">秒杀商品数量</label>
                                                <div class="controls">
                                                    <input type="text" placeholder="" name="goods_num" class="input-xlarge">
                                                    <p class="help-block">请输入商品数量，该数值为大于0的整数</p>
                                                </div>
                                            </div>

                                            <div class="control-group">

                                                <!-- Text input-->
                                                <label class="control-label" for="input01">商品原价</label>
                                                <div class="controls">
                                                    <input type="text" placeholder="" name="goods_cost_price" class="input-xlarge">
                                                    <p class="help-block">可以精确到小数点后1位</p>
                                                </div>
                                            </div>

                                            <div class="control-group">

                                                <!-- Text input-->
                                                <label class="control-label" for="input01">秒杀价格</label>
                                                <div class="controls">
                                                    <input type="text" placeholder="" name="goods_price" class="input-xlarge">
                                                    <p class="help-block"></p>
                                                </div>
                                            </div>

                                            <div class="control-group">
                                                <label class="control-label">商品图片</label>

                                                <!-- Button -->
                                                <div class="controls">
                                                    <lbase:imgUpload name='imgupload' />
                                                    <p class="help-block">图片尺寸：640*320</p>
                                                </div>
                                            </div>

                                            <div class="control-group">

                                                <!-- Text input-->
                                                <label class="control-label" for="input01">开始时间</label>
                                                <div class="controls">
                                                    <input type="text" placeholder="请填写活动开始时间" name="begin_time" class="input-xlarge">
                                                    <p class="help-block">秒杀活动开始时间，格式为2013-09-29 15:30:25</p>
                                                </div>
                                            </div>

                                            <div class="control-group">

                                                <!-- Text input-->
                                                <label class="control-label" for="input01">结束时间</label>
                                                <div class="controls">
                                                    <input type="text" placeholder="请填写活动结束时间" name="stop_time" class="input-xlarge">
                                                    <p class="help-block">秒杀活动结束时间，格式为2013-09-29 15:30:25</p>
                                                </div>
                                            </div>

                                            <div class="control-group">

                                                <!-- Text input-->
                                                <label class="control-label" for="input01">兑换截止时间</label>
                                                <div class="controls">
                                                    <input type="text" placeholder="请填写兑换截止时间" name="exchange_stop_time" class="input-xlarge">
                                                    <p class="help-block">商品兑换截止时间，格式为2013-09-29 15:30:25</p>
                                                </div>
                                            </div>

                                            <div class="control-group">

                                                <!-- Select Basic -->
                                                <label class="control-label">显示状态</label>
                                                <div class="controls">
                                                    <select class="input-xlarge" name="status">
                                                        <option value="1">显示</option>
                                                        <option value="0">隐藏</option></select>
                                                </div>

                                            </div><div class="control-group">

                                                <!-- Text input-->
                                                <label class="control-label" for="input01">排序</label>
                                                <div class="controls">
                                                    <input type="text" placeholder="" name="sort" value="9999" class="input-xlarge">
                                                    <p class="help-block">同时开始的活动，排序越小越靠前</p>
                                                </div>
                                            </div>

                                            <div class="control-group">
                                                <label class="control-label" for="input01">兑换码位数</label>
                                                <div class="controls">
                                                    <input type="text" placeholder="" name="code_num" value="10" class="input-xlarge">
                                                    <p class="help-block">默认为10位</p>
                                                </div>
                                            </div>

                                            <div class="control-group">
                                                <label class="control-label" for="input01">每微信账号参与次数</label>
                                                <div class="controls">
                                                    <input type="text" placeholder="" name="wx_user_num" value="1" class="input-xlarge">
                                                    <p class="help-block">默认为1次，填写0为不限制秒杀次数</p>
                                                </div>
                                            </div>

                                            <div class="control-group">
                                                <label class="control-label">商品说明</label>
                                                <div class="controls">
                                                    <div class="textarea">
                                                        <lbase:editor name="goods_explain" type="editor" width="70%" />
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="control-group">
                                                <label class="control-label">兑换说明</label>
                                                <div class="controls">
                                                    <div class="textarea">
                                                        <textarea type="" class="" name="exchange_explain" style="width:500px;height: 100px"> </textarea>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="control-group">
                                                <label class="control-label">备注</label>
                                                <div class="controls">
                                                    <div class="textarea">
                                                        <textarea type="" class="" name="remark" style="width:500px;height: 100px"> </textarea>
                                                    </div>
                                                </div>
                                            </div>
                                            <div id='pop'></div>

                                            <div class="form-actions">
                                                <button type="button" class="btn btn-primary" id="save">保 存</button>&nbsp;&nbsp;
                                                <a class="btn" href="{$pre_url}">返 回</a>
                                            </div>
                                        </fieldset>
                                    </form>
                                </div>
                                <!--右侧字段区域end-->
                            </div>
                            <!--右侧栏目内容区域end-->
                        </div>

                    </div>
                </div>
                <!--右侧栏目区域end-->
            </div>
            <footer>
                <include file="Public:footer" />
            </footer>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function() {
        var save_button = $('#save');
        save_button.click(function() {
            goods_explain_editor.sync();
            var data = $('form').serialize();
            save_button.attr('disabled', 'disabled');
            $.ajax({
                type: "POST",
                url: app_url + "/" + module_name + "/insert",
                data: data,
                dataType: 'json',
                cache: false,
                success: function(data) {
                    success(data);
                },
                error: function() {
                    error();
                }
            });
        });

        $('#pop').ajaxStart(function() {
            $('#pop').html('<div class="alert alert-info"><button type="button" class="close" data-dismiss="alert">×</button>数据请求中，请稍候...</div>')
                    .fadeIn("slow");
        });

        function success(data) {
            if (data.data == 1) {
                $('#pop').html('<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button>信息添加成功！</div>')
                        .fadeIn("slow")
                        .fadeOut(5000);
            } else {
                $('#pop').html('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button>信息添加失败！</div>')
                        .fadeIn("slow")
                        .fadeOut(5000);
            }
        }


        function error() {
            $('#pop').html('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button>远程服务器请求失败！</div>')
                    .fadeIn("slow")
                    .fadeOut(5000);
        }
    });
</script>

</body>
</html>


